package com.gonsin.gnews.annotations.model;

import com.fasterxml.jackson.annotation.JsonIgnore;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import org.hibernate.annotations.CreationTimestamp;
import org.hibernate.annotations.UpdateTimestamp;

import javax.persistence.*;
import java.util.Date;
import java.util.List;

@Entity
@Table(name = "gs_news_template")
@ApiModel("消息模板")
@Data
//@TableName("gs_news_template")
public class NewsTemplateBean {

    @ApiModelProperty("主键")
    @Column(name = "news_template_key", columnDefinition = "varchar(64) comment '主键'")
    @Id
//    @TableId("news_template_key")
    private String newsTemplateKey;

    @ApiModelProperty("所属的会议中心")
    @Column(name = "edifice_key", columnDefinition = "CHAR(32) comment '所属的会议中心'")
    private String edificeKey;

//    @TableField("platform")
    @ApiModelProperty("模板平台 dingding（钉钉），sms（短信）,qiyewechat（企业微信）,official（公众号）,http（HTTP）,email（邮件），miniapp（微信小程序）")
    @Column(name = "platform", columnDefinition = "VARCHAR(16) comment '所属的会议中心'")
    private String platform;

//    @TableField("template_key")
    @ApiModelProperty("模板类型，指向模板类型")
    @Column(name = "template_key", columnDefinition = "varchar(64) comment '模板名字'")
    private String templateKey;

//    @TableField("name")
    @ApiModelProperty(value = "该模板的名字（必填）", required = true)
    @Column(name = "name", columnDefinition = "VARCHAR(64) comment '该模板的名字（必填）'", nullable = false)
    private String name;

//    @TableField("title")
    @ApiModelProperty("消息的标题（钉钉消息、企业微信消息有效，且必填）")
    @Column(name = "title", columnDefinition = "text comment '消息的标题（钉钉消息、企业微信消息有效，且必填）'")
    private String title;

//    @TableField("url")
    @ApiModelProperty("跳转连接，钉钉、企业微信、公众号有效（非必填）")
    @Column(name = "url", columnDefinition = "TEXT comment '跳转连接，钉钉、企业微信、公众号有效（非必填）'")
    private String url;

//    @TableField(value = "params", typeHandler = NewsParamsPoConverter.class)
    @ApiModelProperty("参数（数据库用一个json存储）")
    @Column(name = "params", columnDefinition = "TEXT comment '参数（数据库用一个json存储）'")
    @Convert(converter = NewsParamsPoConverter.class)
    private List<NewsParamsPo> params;

//    @TableField("content")
    @ApiModelProperty("邮件富文本内容（邮件必填）")
    @Column(name = "content", columnDefinition = "LONGTEXT comment '邮件富文本内容（邮件必填）'")
    private String content;

//    @TableField("sms_content")
    @ApiModelProperty("短信模板内容（后台获取，不用填）")
    @Column(name = "sms_content", columnDefinition = "TEXT comment '短信模板内容（后台获取，不用填）'")
    private String smsContent;

//    @TableField("sms_template_code")
    @ApiModelProperty("阿里上的短信模板templateCode值，公众号模板消息里的templateId")
    @Column(name = "sms_template_code", columnDefinition = "varchar(64) comment '阿里上的短信模板templateCode值，公众号模板消息里的templateId'")
    private String templateCode;

//    @TableField("method")
    @ApiModelProperty("模板平台为http时有效，表示发送http请求的方法，可取值 GET\\POST")
    @Column(name = "method", columnDefinition = "VARCHAR(10) comment '模板平台为http时有效，表示发送http请求的方法，可取值 GET\\\\POST'")
    private String method;

//    @TableField("enable")
    @ApiModelProperty("是否启用")
    @Column(name = "enable", columnDefinition = "tinyint comment '是否启用'")
    private boolean enable;

    @ApiModelProperty("是否为初始化数据")
    @Column(name = "init", columnDefinition = "tinyint comment '是否为初始化数据'")
    private Boolean init;

    @ApiModelProperty("默认内容")
    @Column(name = "default_content", columnDefinition = "LONGTEXT comment '默认内容'")
    private String defaultContent;

//    @TableField("create_time")
    @ApiModelProperty("创建时间")
    @CreationTimestamp
    @Column(name = "create_time", columnDefinition = "datetime comment '创建时间'")
    private Date createTime;

//    @TableField("update_time")
    @ApiModelProperty("上次修改时间")
    @Column(name = "update_time", columnDefinition = "datetime comment '上次修改时间'")
    @UpdateTimestamp
    private Date updateTime;

    @ApiModelProperty("排序")
    @Column(name = "sort", columnDefinition = "int comment '排序'",nullable = false)
    private int sort;

//    @TableField("version")
    @ApiModelProperty("该字段当前修改版本")
    @Version
    @Column(name = "version", columnDefinition = "bigint comment '该字段当前修改版本'")
    private long version;

//    @TableField("gs_delete")
    @ApiModelProperty("是否已删除(不会传递到前端)")
    @JsonIgnore
    @Column(name = "gs_delete", columnDefinition = "tinyint comment '是否已删除(不会传递到前端)'")
    private boolean delete = false;     // 是否已删除(采用逻辑删除)

}
